//
//  KLCommentCollectionViewCell.m
//  KunLun
//
//  Created by Mac on 2018/1/17.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "KLCommentCollectionViewCell.h"
#import "STXingXIngView.h"
#import "STTextView.h"
@interface KLCommentCollectionViewCell()
@property(nonatomic, strong) UIImageView                     *goodBanerImageView;
@property(nonatomic, strong) STLabel                         *titleLable;//名字
@property(nonatomic, strong) STLabel                         *numLable;//数量
@property(nonatomic, strong) STLabel                         *moneyLable;//好多钱


@end
@implementation KLCommentCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    //商品
    self.backgroundColor = [UIColor whiteColor];
    UIControl * grayView = [[UIControl alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 120)];
    grayView.backgroundColor  = UIColorFromRGBA(0xf2f2f2);
    [grayView addTarget:self action:@selector(onSetctedControl) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:grayView];
    
    self.goodBanerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 90, 90)];
    self.goodBanerImageView.image = [UIImage imageNamed:@"06"];
    [grayView addSubview:self.goodBanerImageView];
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.goodBanerImageView.right + 10, self.goodBanerImageView.top + 5, UIScreenWidth - 20 - self.goodBanerImageView.right, 35)
                                                text:@"鲜榨大橘子打开了手机读卡老实交代安达市打"
                                           textColor:KL_firstTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    self.titleLable.numberOfLines = 0;
    [grayView addSubview:self.titleLable];
    
    self.numLable = [[STLabel alloc] initWithFrame:CGRectMake(self.goodBanerImageView.right + 10, self.titleLable.st_bottom + 5, UIScreenWidth - 20 - self.goodBanerImageView.right, 15)
                                              text:@"数量：*2"
                                         textColor:KL_secendTextColor
                                              font:13
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentLeft];
    [grayView addSubview:self.numLable];
    
    self.moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(self.goodBanerImageView.right + 10, self.titleLable.st_bottom , UIScreenWidth - 20 - self.goodBanerImageView.right, 16)
                                                text:@"￥1374"
                                           textColor:KL_redColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentRight];
    self.moneyLable.st_right = UIScreenWidth - 10;
    [grayView addSubview:self.moneyLable];
    
    
    STLabel * qulityLable = [[STLabel alloc] initWithFrame:CGRectMake(20, grayView.bottom, 70, 40)
                                                      text:@"商品评分:"
                                                 textColor:KL_firstTextColor
                                                      font:15
                                               isSizetoFit:NO
                                             textAlignment:NSTextAlignmentLeft];
    [self addSubview:qulityLable];
    self.xingxingView = [[STXingXIngView alloc] initWithFrame:CGRectMake(qulityLable.right + 10, 0, 150, 40) maxsNum:5];
    self.xingxingView.centerY = qulityLable.centerY;
    self.xingxingView.chosedNum = 1;
    [self.xingxingView makeXingXingSelectedWithNum:1];
    [self addSubview:self.xingxingView];
    
    self.textView = [[STTextView alloc] initWithFrame:CGRectMake(20,self.xingxingView.bottom + 10, UIScreenWidth - 40, 120)];
    self.textView.placeholder = @"请输入评价内容";
    self.textView.backgroundColor = KL_backgroundColor;
    [self addSubview:self.textView];

    
    STButton * confimButton = [[STButton alloc] initWithFrame:CGRectMake(30, self.textView.bottom + 60, UIScreenWidth - 60 , 44)
                                                        title:@"提交评价"
                                                   titleColor:[UIColor whiteColor]
                                                    titleFont:18
                                                 cornerRadius:10
                                              backgroundColor:KL_BlueBackGroundColor
                                              backgroundImage:nil
                                                        image:nil];

    confimButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.commentButton = confimButton;
    [self addSubview:self.commentButton];
    
}
- (void)onSetctedControl{
    if (self.goodAction) {
        self.goodAction(nil);
    }
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self endEditing:YES];
}
- (void)setModel:(KLOrderGoodModel *)model{
    _model = model;
    [self.goodBanerImageView sd_setImageWithURL:[NSURL URLWithString:model.exhibition_map] placeholderImage:KL_placeHoderImage];
    
    self.titleLable.text = [NSString stringWithFormat:@"%@",model.goods_name];
    
    self.numLable.text = [NSString stringWithFormat:@"数量:%@",model.goods_num];
    
    CGFloat  moeny;
    if (model.goods_price) {
        moeny = model.goods_price.floatValue * model.goods_num.integerValue;
        self.moneyLable.text = [NSString stringWithFormat:@"￥%0.2f",moeny];
    }
}
@end
